ApplicationManager = function() {
    var menuBarPanel = null;
    var contentPanel = null;
    var statusBarPanel = null;
    var currentUser = null;
    var currentMaHd = null;
    var hdInfo = null;
    var isEditHd = null;
    var callbackMsg = null;
    var traHangFrom = null;
    var denHangFrom = null;
    
	return {
		/************************  BUILD MENU   *******************/
		mainForm : null,
		subForm : null,
		mainContainer : null, 
		
		buildMainWindow : function() {
        	menuBarPanel = MenuBar.init();
            contentPanel = Content.init();
            statusBarPanel = StatusBar.init();
            
			this.appViewPort = new Ext.Viewport({
                layout : 'border',
                items : [menuBarPanel, contentPanel/*, statusBarPanel*/]
            });	
		},
		
		/*Open a specific menu item*/
		openMenu : function(menuId){
			MenuBar.setActiveMenu(menuId);
		},
		
		openContentPage : function(menuId){
			ApplicationManager.isEditHd = false;
			if (menuId == MenuItemId.suaHD) {
				ApplicationManager.isEditHd = true
			}
			var pageFileName = MenuMapping[menuId];
			var contentContainer = eval("new " + pageFileName + "()");
			Content.renderContentItem(contentContainer);
		},
		
		startApplication : function() {
			Ext.QuickTips.init();
			ApplicationManager.buildMainWindow();
			
			/* Get the logged user info */
			Ext.Ajax.request({
                url : 'user/loadLoggedUserInfo', method : 'POST', 
                success : function(object, opts){
                	// Add logged user info and logout link.
                	var response = Ext.decode(object.responseText);
                	
                	// Update current user to show on logout bar.
                	ApplicationManager.currentUser = response.user;
                	MenuBar.buildMenu();
                	ApplicationManager.openMenu(MenuItemId.taoHD);// DO NOT COMMIT
                }, failure : Ext.emptyFn
            });
		}
	}
}();
